﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Web.UI.WebControls;

/// <summary>
/// Summary description for MyCheckBox
/// </summary>
public class MyCheckBox
{
	public MyCheckBox()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public void ChonTatCa(GridView gridView, string id, CheckBox checkBox)
    {
        for (int i = 0; i < gridView.Rows.Count; i++)
        {
            CheckBox _checkBox = (CheckBox)(gridView.Rows[i].Cells[0].FindControl(id));
            _checkBox.Checked = true;
        }
    }

    public void HuyTatCa(GridView gridView, string id, CheckBox checkBox)
    {
        for (int i = 0; i < gridView.Rows.Count; i++)
        {
            CheckBox _checkBox = (CheckBox)(gridView.Rows[i].Cells[0].FindControl(id));
            _checkBox.Checked = false;
        }
    }

    public Boolean KiemTraCheck(GridView gridView, string checkBoxName)
    {
        int dem = 0;
        
        for (int i = 0; i < gridView.Rows.Count; i++)
        {
            CheckBox checkBox = (CheckBox)(gridView.Rows[i].Cells[0].FindControl(checkBoxName));
            if (checkBox.Checked)
            {
                dem += 1;
            }
        }

        if (dem > 0)
        {
            return true;
        }
        return false;
    }
}